home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 342_01.zip / I8255FN.H < prev    next >
C/C++ Source or Header  |  1993-04-03  |  4KB  |  125 lines

  1. /*-
  2.  *  ----------------------------------------------------------------------
  3.  *  File        :   8255FN.H
  4.  *  Creator     :   Blake Miller
  5.  *  Version     :   01.00.00            February 1991
  6.  *  Language    :   Microsoft Quick C   Version 2.0
  7.  *              :   Microsoft C         Version 5.1
  8.  *  Purpose     :   Intel 8255 Compatible Digital IO Functions
  9.  *  ----------------------------------------------------------------------
  10.  */
  11.  
  12. #define I8255FN_H_DEFINED   1
  13.  
  14. /*  Definitions ------------------------------*/
  15.  
  16. /*- The address definitions are set up for the 8255.
  17.  *  The base address should be passed to the I8255_init() function.
  18.  */
  19.  
  20. #define I8255_PORTA(X)   (X + 0) /* 8255 PORT A address  */
  21. #define I8255_PORTB(X)   (X + 1) /* 8255 PORT B address  */
  22. #define I8255_PORTC(X)   (X + 2) /* 8255 PORT C address  */
  23. #define I8255_CNTRL(X)   (X + 3) /* 8255 CONTROL address */
  24.  
  25. #define I8255_MAXCH  0x03    /* three IO ports       */
  26.  
  27. #define I8255_SET    0x80    /* configure set bit    */
  28.  
  29. #define I8255_PA_M0  0x20    /* Port A I/O Mode 0 : Basic            */
  30. #define I8255_PA_M1  0x40    /* Port A I/O Mode 1 : Strobed          */
  31. #define I8255_PA_M2  0x60    /* Port A I/O Mode 2 : Bidirectional    */
  32. #define I8255_PB_M0  0x00    /* Port B I/O Mode 0 : Basic            */
  33. #define I8255_PB_M1  0x04    /* Port B I/O Mode 1 : Strobed          */
  34.  
  35. /*- These are the bit masks for the port input configurations.
  36.  *  These corresponding bits are 0 if the port is configured for output.
  37.  */
  38. #define I8255_CL_IN  0x01    /* Port C Low  Input    */
  39. #define I8255_PB_IN  0x02    /* Port B      Input    */
  40. #define I8255_CH_IN  0x08    /* Port C High Input    */
  41. #define I8255_PA_IN  0x10    /* Port A      Input    */
  42.  
  43. /*- 8255 Digital select mode:
  44.  *  PA 0-7 output, PB 0-7 output, PC 0-3 output, PC 4-7 output
  45.  *  ALL ports in Mode 0
  46.  */
  47. #define I8255_ALL_OP I8255_SET
  48.  
  49. /*- 8255 Digital select mode:
  50.  *  PA 0-7 input, PB 0-7 input, PC 0-3 input, PC 4-7 input
  51.  *  ALL ports in Mode 0
  52.  */
  53. #define I8255_ALL_IP ( I8255_SET | I8255_CL_IN | I8255_PB_IN | \
  54.                        I8255_CH_IN | I8255_PA_IN )
  55.  
  56. /*  Error Definitions ------------------------*/
  57.  
  58. #define I8255_ST_OK  0x0000  /* OK               */
  59. #define I8255_ST_BB  0x0001  /* Bad Bit number   */
  60. #define I8255_ST_BP  0x0001  /* Bad Port number  */
  61.  
  62. /*  Data Structure ---------------------------*/
  63.  
  64. #if !defined ( I8255DAT_DEFINED )
  65.  
  66. typedef struct I8255dat_struct {
  67.  
  68.     int             base;   /* 8255 address */
  69.     int             stat;   /* status flag  */
  70.     unsigned char   mode;   /* current mode */
  71.     unsigned char   adat;   /* port A data  */
  72.     unsigned char   bdat;   /* port B data  */
  73.     unsigned char   cdat;   /* port C data  */
  74.  
  75.     } I8255DAT;
  76.  
  77. #define I8255DAT_DEFINED 1
  78. #endif
  79.  
  80. /*  Function Prototypes ----------------------*/
  81.  
  82. /*  These are the INP and OUTP functions used to
  83.  *  write and read from an 80X86 IO Port.
  84.  */
  85. extern  void chp_portwt (int, unsigned char  );
  86. extern  void chp_portrd (int, unsigned char *);
  87.  
  88. #if !defined ( I8255F01_C_DEFINED )
  89. extern void I8255_init (I8255DAT *, int);
  90. #endif
  91. #if !defined ( I8255F02_C_DEFINED )
  92. extern void I8255_config (I8255DAT *, int, int, int, int);
  93. #endif
  94.  
  95. #if !defined ( I8255F03_C_DEFINED )
  96. extern void I8255_bitput (I8255DAT *, int, int);
  97. #endif
  98. #if !defined ( I8255F04_C_DEFINED )
  99. extern void I8255_bitget (I8255DAT *, int, int *);
  100. #endif
  101.  
  102. #if !defined ( I8255F05_C_DEFINED )
  103. extern void I8255_put_byte (I8255DAT *, int, unsigned char);
  104. #endif
  105. #if !defined ( I8255F06_C_DEFINED )
  106. extern void I8255_get_byte (I8255DAT *, int, unsigned char *);
  107. #endif
  108.  
  109. #if !defined ( I8255F07_C_DEFINED )
  110. extern void I8255_dump_bytes (I8255DAT *);
  111. #endif
  112. #if !defined ( I8255F08_C_DEFINED )
  113. extern void I8255_load_bytes (I8255DAT *);
  114. #endif
  115.  
  116. #if !defined ( I8255F09_C_DEFINED )
  117. extern  void I8255_bittog (I8255DAT *, int);
  118. #endif
  119.  
  120. /*-
  121.  *  ----------------------------------------------------------------------
  122.  *  END I8255FN.H Header File
  123.  *  ----------------------------------------------------------------------
  124.  */
  125.